//
//  HRSoundCoverCell.m
//  Hear
//
//  Created by mac on 2017/6/6.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRSoundCoverCell.h"
@interface HRSoundCoverCell ()
@property (nonatomic, strong)UIImageView *coverImageView;
@property (nonatomic, strong)UILabel *descLabel;

@end
@implementation HRSoundCoverCell

-(UIImage*) OriginImage:(UIImage *)image scaleToSize:(CGSize)size
{
    UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
    
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    
    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return scaledImage;   //返回的就是已经改变的图片
}

-(void)setImageNameStr:(NSString *)imageNameStr{
    _imageNameStr = imageNameStr;
    self.coverImageView.image = [self OriginImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imageNameStr ofType:@"jpg"]] scaleToSize:CGSizeMake(self.width-20, self.width-20)];
    
    

    
}

-(void)setDescStr:(NSString *)descStr{
    _descStr = descStr;
    self.descLabel.text = descStr;

}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self setupViews];
    }
    return self;
}




- (void)setupViews{
    self.coverImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
    self.coverImageView.contentMode = UIViewContentModeScaleToFill;
    [self addSubview:self.coverImageView];
    
//    self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.coverImageView.bottom+5, self.width, 20)];
//    self.descLabel.textColor = [UIColor blackColor];
//    self.descLabel.font = CustomUIFont(13);
//    [self addSubview:self.descLabel];
//    self.descLabel.textAlignment = 1;
    
    
    self.selectImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.width-30, 5, 30, 30)];
    self.selectImageView.hidden = YES;
    self.selectImageView.image = [UIImage imageNamed:@"对"];
    self.selectImageView.contentMode = UIViewContentModeScaleToFill;
    [self addSubview:self.selectImageView];
}

@end
